package cate.game.play.skill.passive.furniture;

import cate.common.table.d.GDSkill;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 奇数回合恢复自身5%最大生命值;
 *  偶数回合选择非自身1名优先后排的目标进行庇护，完全分摊其伤害15%，自身最多扣除15%最大生命值，庇护效果自身生命低于30%或我方人数小于3时无法触发
 */
public class 四羊奇偶PH extends PassiveHandler {

	private double 恢复系数;

	private int 援护buff;

	//恢复系数=500&援护buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		恢复系数 = args.getWDouble("恢复系数", 0d);
		援护buff = args.getInt("援护buff", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		if (skill.owner.isAlive()) {
			if (action.getRound().isOddRound()) {
				skill.owner.attr.passiveHeal(action, skill.owner.attr.total().hpTotal() * 恢复系数);
			} else {
				TargetFilterParam param = new TargetFilterParam().scopeSet(GDSkill.Scope.FRIENDS).specialSet(GDSkill.CSpecial.BACK_ONE_ROW);
				Fighter target = TargetSelector.findOne(skill.owner, action.getTeamVs(), param);
				if(target!=null){
					target.buff.tryAddByTid(action, skill.owner, 援护buff);
				}
			}
		}
	}
}
